<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>

<body>
    <div id="app">
        <h3>时间:{{date|filterDate("yyyy年mm月dd日")}} </h3>
        <h3>时间:{{date|filterDate("yyyy/mm/dd")}} </h3>
        <h3>时间:{{date|filterDate("yyyy-mm-dd")}} </h3>
    </div>

</body>
<script>
    new Vue({
        el: "#app",
        data: {
            date: new Date()
        },
        filters: {
            filterDate(str,tempstr) {//默认参数就是 fitlerDate|前面的值  第二个才是filter的真正参数
                let date = new Date(str);
                let year = date.getFullYear();
                let month = date.getMonth() + 1;
                let day = date.getDate();
                return tempstr.replace("yyyy",year).replace("mm",month).replace("dd",day);
            }
        }

    })

</script>

</html>